\documentclass{ctexart}
\usepackage{listings}%插入代码
\usepackage{geometry}%设置页面大小边距等
\usepackage{authblk}%作者机构等信息
\usepackage{graphicx}%插入图片
\usepackage{url}%Bib中引用网页
\usepackage{amssymb}%为了用\mathbb
\usepackage{amsmath}%数学方程的显示
%\usepackage{amsthm}%数学定理
\usepackage{listings}%插入代码
\usepackage{fancyhdr}%设置页眉页脚
\usepackage{lastpage}%总页数
\usepackage{hyperref}%引用网页
\usepackage{xcolor}
\usepackage{tikz}



\geometry{a4paper,left=2cm,right=2cm,top=2cm,bottom=2cm}%一定要放在前面！
\pagestyle{fancy}%设置页眉页脚
\lhead{周游\ 3200106105}%页眉左
\chead{Numerical Analysis homwork01}%页眉中
\rhead{2022/09/21}%章节信息
\cfoot{\thepage/\pageref{LastPage}}%当前页，记得调用前文提到的宏包
\rfoot{浙江大学数学科学学院}
\renewcommand{\headrulewidth}{0.1mm}%页眉线宽，设为0可以去页眉线
\renewcommand{\footrulewidth}{0.1mm}%页脚线宽，设为0可以去页眉线
\setlength{\headwidth}{\textwidth}

\hypersetup{%设置网页链接颜色等
    colorlinks=true,%链接将会有颜色，默认是红色
    linkcolor=blue,%内部链接，那些由交叉引用生成的链接将会变为蓝色（blue）
    filecolor=magenta,%链接到本地文件的链接将会变为洋红色（magenta）
    urlcolor=blue,%链接到网站的链接将会变为蓝绿色（cyan）
    }

\newtheorem{theorem}{Theorem}
\newtheorem{proof}{Proof:}
\newtheorem{solution}{Solution:}

\begin{document}
%\newpage
\section*{1.8.2 Programming assignments}
组织架构：                           
EquationSolver.h是求解器的库文件,        
proX.cpp表示第X题答案的源码,
可执行文件proX能输出第X题答案。 \par
代码运行方式：
输入make命令编译出可执行文件，proX表示第X题答案，
输入bash run执行之，终端输出答案。
\subsection*{A}
\begin{solution}
The abstract class is in EquationSolver.h. \\
The pro.cpp is the test code.               \\
The out put :            
\begin{lstlisting}
Question A:                     
f(x) = (x-1)^3 for test         
The bisection result is 1.00    
The Newton result is 1.00       
The secant result is 1.00  
\end{lstlisting}      
\end{solution}

\subsection*{B}
\begin{solution}
编译运行proB.cpp, 输出答案
\begin{lstlisting}
Question B: 
The bisection result of f1 is 0.86
The bisection result of f2 is 0.64
The bisection result of f3 is 1.83
The bisection result of f4 is 0.11788
But f4(x*) = -12184144540576264.00000 , f4(x) is not continue in [0,4]
\end{lstlisting}
f4不满足二分法条件，在[0,4]区间内不连续
\end{solution}

\subsection*{C}
\begin{solution}
编译运行proC.cpp, 输出答案
\begin{lstlisting}
Question C: 
The Newton result near 4.5 is 4.49
The Newton result near 7.7 is 7.73
\end{lstlisting}
\end{solution}

\subsection*{D}
\begin{solution}
编译运行proD.cpp, 输出答案
\begin{lstlisting}
Question D: 
The secant result of f1 is 3.14
The secant result of f2 is 1.31
The secant result of f3 is -0.19
In S3, we change x0=3 x1=2 
The secant result of f3plus is 0.45
Because there are different solutions in one equation.
\end{lstlisting}
由于题中函数不止一个根，故取不同初始值可能收敛到不同根。
\end{solution}

\subsection*{E}
\begin{solution}
编译运行proE.cpp, 输出答案
\begin{lstlisting}
Question E: 
The bisection result is 0.17
The Newton result is 0.17
The secant result is 0.17
\end{lstlisting}
\end{solution}

\subsection*{F}
\begin{solution}
编译运行proF.cpp, 输出答案
\begin{lstlisting}
Question F: 
(a) Choose x0 = pi/4
The Newton result of alpha is 0.58
Change unit: alpha = 32.97 degree

(b) Choose x0 = 33 degree
The Newton result of alpha is 33.17 degree

(c) Choose x1 = 33 degree, x0 = 75 degree 
The Secant result of alpha is 33.17 degree
Choose x1 = 33 degree, x0 = -327 degree 
The Secant result of alpha is -nan degree
\end{lstlisting}
当$x_1$=33°，$x_0$足够远时，割线不再能近似切线，故出现错误
\end{solution}


\end{document} 
